﻿using System;
using FluentNHibernate.Mapping;
using Kratos.Framework.ContentManagement.Models.SystemRights;

namespace Kratos.Framework.ContentManagement.Maps.SystemRights
{
    public class GroupMap : ClassMap<Group>
    {
        public GroupMap()
        {
            Id(g => g.Id).GeneratedBy.Identity().UnsavedValue(null);
            Map(g => g.GroupName);
            Map(g => g.CreateTime).Default(DateTime.Now.ToString());
            Map(g => g.Description);
            Map(g => g.State).CustomType<GroupState>();

            //HasManyToMany<ActionPermission>(g => g.ActionPermissions)
            //    .AsBag()
            //    .Not.LazyLoad()
            //    .ParentKeyColumn("GroupId")
            //    .ChildKeyColumn("ActionId")
            //    .Table("GroupAction");

            //HasManyToMany<UserInfo>(g => g.Users)
            //    .AsBag()
            //    .Not.LazyLoad()
            //    .Inverse().Cascade.All()
            //    .ParentKeyColumn("GroupId")
            //    .ChildKeyColumn("UserId")
            //    .Table("UserGroup");
        }
    }
}
